package dtm

type LoginRequest struct {
	GrantType string `json:"grantType"`
	Username  string `json:"username"`
	Password  string `json:"password"`
	Scope     string `json:"scope"`
	Lang      string `json:"lang"`
}

type LoginResponse struct {
	Token string `json:"token"`
}

type CompanyListResponse struct {
	OdataContext string     `json:"@odata.context"`
	Value        []*Company `json:"value"`
}

type Company struct {
	CompanyId       int64    `json:"companyId"`
	Code            string   `json:"code"`
	Name            string   `json:"name"`
	Enabled         bool     `json:"enabled"`
	Notes           string   `json:"notes"`
	Address         string   `json:"address"`
	Town            string   `json:"town"`
	CountryState    string   `json:"countryState"`
	ZipCode         string   `json:"zipCode"`
	Landline        string   `json:"landline"`
	Mobile          string   `json:"mobile"`
	ActivationDate  string   `json:"activationDate"`
	LicenseCode     string   `json:"licenseCode"`
	ExpirationDate  string   `json:"expirationDate"`
	ResellerCode    string   `json:"resellerCode"`
	ProductId       int64    `json:"productId"`
	ProductName     string   `json:"productName"`
	ProductSlotName string   `json:"productSlotName"`
	TimeZoneId      string   `json:"timeZoneId"`
	Lang            string   `json:"lang"`
	OutOfOrder      bool     `json:"outOfOrder"`
	Roles           []string `json:"roles"`
	FeatureSummary  []string `json:"featureSummary"`
}

type CompanyTokenResponse struct {
	Token      string `json:"token"`
	Expiration int    `json:"expiration"`
	Endpoint   string `json:"endpoint"`
}

type SupportSettingsResponse struct {
	SettingId                 string                     `json:"settingId"`
	Value                     interface{}                `json:"value"` // 可能是布尔，也可能是字符串，也可能是数字
	MilkingAggregationSetting *MilkingAggregationSetting `json:"milkingAggregationSetting"`
	Description               string                     `json:"description"`
}

type UpdateLanguageRequest struct {
	Lang string `json:"lang"`
}

type MilkingAggregationSetting struct {
	PenIds     []int `json:"penIds"`
	PenTypeIds []int `json:"penTypeIds"`
}

type ConfigurationsResponse struct {
	ConfigId string `json:"configId"`
	Status   bool   `json:"status"`
}

type SupportVersionResponse struct {
	AppVersion string `json:"appVersion"`
	DBVersion  string `json:"dbVersion"`
}

type MachineTypesResponse struct {
	OdataContext string `json:"@odata.context"`
	Value        []struct {
		MachineTypeId int64  `json:"machineTypeId"`
		Description   string `json:"description"`
	} `json:"value"`
}

type MachineResponse struct {
	OdataContext string `json:"@odata.context"`
	Value        []struct {
		MachineId            int64  `json:"machineId"`
		Name                 string `json:"name"`
		Capacity             int    `json:"capacity"`
		Description          string `json:"description"`
		SerAlfa              string `json:"serAlfa"`
		Model                string `json:"model"`
		XmlVersion           string `json:"xmlversion"`
		WiFiAddress          string `json:"wiFiAddress"`
		Note                 string `json:"note"`
		Enabled              bool   `json:"enabled"`
		Transmitted          bool   `json:"transmitted"`
		MachineTypeId        int    `json:"machineTypeId"`
		Volume               int    `json:"volume"`
		SerAlfaSensor        string `json:"serAlfaSensor"`
		NextScheduledSyncUtc string `json:"nextScheduledSyncUtc"`
		ReScheduleEveryday   bool   `json:"reScheduleEveryday"`
		RowVersion           string `json:"rowVersion"`
	} `json:"value"`
}

type CustomersResponse struct {
	CustomerId int    `json:"customerId"`
	Name       string `json:"name"`
}

type PenValue struct {
	OdataContext          string       `json:"@odata.context,omitempty"`
	PenId                 int          `json:"penId,omitempty"`
	Name                  string       `json:"name,omitempty"`
	NCows                 int          `json:"ncows,omitempty"`
	CustomerId            int          `json:"customerId,omitempty"`
	CustomerName          string       `json:"customerName,omitempty"`
	AdjPerc               float64      `json:"adjPerc,omitempty"`
	McboxId               int          `json:"mcboxId,omitempty"`
	McboxDescription      string       `json:"mcboxDescription,omitempty"`
	Note                  string       `json:"note,omitempty"`
	Enabled               bool         `json:"enabled,omitempty"`
	PenTypeId             int          `json:"penTypeId,omitempty"`
	PenTypeDescription    string       `json:"penTypeDescription,omitempty"`
	PenSubTypeId          int          `json:"penSubTypeId,omitempty"`
	PenSubTypeDescription string       `json:"penSubTypeDescription,omitempty"`
	Transmitted           bool         `json:"transmitted,omitempty"`
	WeightCowTheo         float64      `json:"weightCowTheo,omitempty"`
	DmWeightCowTheo       float64      `json:"dmWeightCowTheo,omitempty"`
	TotalWeight           float64      `json:"totalWeight,omitempty"`
	DmTotalWeight         float64      `json:"dmTotalWeight,omitempty"`
	NewWeightCow          float64      `json:"newWeightCow,omitempty"`
	NewDmWeightCow        float64      `json:"newDmWeightCow,omitempty"`
	NewTotalWeight        float64      `json:"newTotalWeight,omitempty"`
	NewDmTotalWeight      float64      `json:"newDmTotalWeight,omitempty"`
	LastModify            string       `json:"lastModify,omitempty"`
	Premix                bool         `json:"premix,omitempty"`
	RowVersion            string       `json:"rowVersion,omitempty"`
	PenRation             []*PenRation `json:"penRation"`
}

type GetPensList struct {
	OdataContext string      `json:"@odata.context"`
	Value        []*PenValue `json:"value"`
}

type PenRation struct {
	RationNumber     int     `json:"rationNumber,omitempty"`
	RationPerc       int     `json:"rationPerc,omitempty"`
	RationPercAdj    int     `json:"rationPercAdj,omitempty"`
	RecipeId         int     `json:"recipeId,omitempty"`
	RecipeName       string  `json:"recipeName,omitempty"`
	NewWeightCow     float64 `json:"newWeightCow,omitempty"`
	NewTotalWeight   float64 `json:"newTotalWeight,omitempty"`
	NewDmWeightCow   float64 `json:"newDmWeightCow,omitempty"`
	NewDmTotalWeight float64 `json:"newDmTotalWeight,omitempty"`
	BatchId          int     `json:"batchId,omitempty"`
	BatchName        string  `json:"batchName,omitempty"`
}

type RefusedByDayResponse struct {
	OdataContext string                `json:"@odata.context"`
	OdataCount   int                   `json:"@odata.count"`
	Value        []*RefusedByDayValues `json:"value,omitempty"`
}

type RefusedByDayValues struct {
	RefusedDate        string  `json:"refusedDate,omitempty"`
	PenId              int     `json:"penId,omitempty"`
	PenName            string  `json:"penName,omitempty"`
	PenTypeId          int     `json:"penTypeId,omitempty"`
	PenTypeName        string  `json:"penTypeName,omitempty"`
	FeederId           int     `json:"feederId,omitempty"`
	FeederName         string  `json:"feederName,omitempty"`
	CustomerId         int     `json:"customerId,omitempty"`
	CustomerName       string  `json:"customerName,omitempty"`
	ActualCustomerId   int     `json:"actualCustomerId,omitempty"`
	ActualCustomerName string  `json:"actualCustomerName,omitempty"`
	MachineId          int     `json:"machineId,omitempty"`
	MachineName        string  `json:"machineName,omitempty"`
	TotalRefusedQty    float64 `json:"totalRefusedQty,omitempty"`
	Score              int     `json:"score"`
	NCows              int     `json:"ncows"`
	RawRefusedId       int     `json:"rawRefusedId"`
	Count              int     `json:"count"`
	Mode               int     `json:"mode"`
}

type BatchHistResponse struct {
	OdataContext string            `json:"@odata.context"`
	OdataCount   int               `json:"@odata.count"`
	Value        []*BatchHistValue `json:"value,omitempty"`
}

type BatchHistValue struct {
	EnableLoadId         int         `json:"elabLoadId,omitempty"`
	Unloaded             float64     `json:"unloaded,omitempty"`
	ErrPercUnload        float64     `json:"errPercUnload,omitempty"`
	LoadDate             string      `json:"loadDate,omitempty"`
	LoadStartTime        string      `json:"loadStartTime,omitempty"`
	LoadEndTime          string      `json:"loadEndTime,omitempty"`
	UnloadStartTime      string      `json:"unloadStartTime,omitempty"`
	UnloadEndTime        string      `json:"unloadEndTime,omitempty"`
	RecipeId             int         `json:"recipeId,omitempty"`
	RecipeName           string      `json:"recipeName,omitempty"`
	Premix               bool        `json:"premix,omitempty"`
	CustomerId           int         `json:"customerId,omitempty"`
	CustomerName         string      `json:"customerName,omitempty"`
	NCows                int         `json:"ncows,omitempty"`
	MachineId            int         `json:"machineId,omitempty"`
	MachineName          string      `json:"machineName,omitempty"`
	TargetWeightOnScale  float64     `json:"targetWeightOnScale,omitempty"`
	TargetWeightWithCorr float64     `json:"targetWeightWithCorr,omitempty"`
	Loaded               float64     `json:"loaded,omitempty"`
	ErrPercLoad          float64     `json:"errPercLoad,omitempty"`
	FeederId             int         `json:"feederId,omitempty"`
	FeederName           string      `json:"feederName,omitempty"`
	TargetWeight         float64     `json:"targetWeight,omitempty"`
	BatchId              int         `json:"batchId,omitempty"`
	BatchName            string      `json:"batchName,omitempty"`
	FeederErrCost        float64     `json:"feederErrCost,omitempty"`
	LoadPercError        float64     `json:"loadPercError,omitempty"`
	PercByNirCorrection  float64     `json:"percByNirCorrection,omitempty"`
	CorrectionCost       float64     `json:"correctionCost,omitempty"`
	TotalCost            float64     `json:"totalCost,omitempty"`
	QtyDmCowNocorr       float64     `json:"qtyDmCowNocorr,omitempty"`
	QtyDmCowCorr         int         `json:"qtyDmCowCorr,omitempty"`
	MixTime              int         `json:"mixTime,omitempty"`
	MixTimeCorr          int         `json:"mixTimeCorr,omitempty"`
	Omg                  interface{} `json:"omg"`
	TotalLoad            string      `json:"totalLoad,omitempty"`
	TotalUnload          string      `json:"totalUnload,omitempty"`
	TotalPause           string      `json:"totalPause"`
	TotalTime            string      `json:"totalTime,omitempty"`
}

type FormulationResponse struct {
	OdataContext string               `json:"@odata.context"`
	OdataCount   int                  `json:"@odata.count"`
	Value        []*FormulationValues `json:"value,omitempty"`
}

type FormulationValues struct {
	RecipeId            int                 `json:"recipeId,omitempty"`
	Transmitted         bool                `json:"transmitted,omitempty"`
	RevMax              int                 `json:"revMax,omitempty"`
	RevMin              int                 `json:"revMin,omitempty"`
	RevDate             string              `json:"revDate,omitempty"`
	LastModify          string              `json:"lastModify,omitempty"`
	ByTotals            bool                `json:"byTotals,omitempty"`
	WaterAdjustmentType int                 `json:"waterAdjustmentType,omitempty"`
	RowVersion          string              `json:"rowVersion,omitempty"`
	Factory             bool                `json:"factory,omitempty"`
	Name                string              `json:"name,omitempty"`
	TotWeightIngByPerc  float64             `json:"totWeightIngByPerc,omitempty"`
	MixTime             int                 `json:"mixTime,omitempty"`
	Note                string              `json:"note,omitempty"`
	Enabled             bool                `json:"enabled,omitempty"`
	FeederId            int                 `json:"feederId,omitempty"`
	FeederName          string              `json:"feederName,omitempty"`
	CustomerId          int                 `json:"customerId,omitempty"`
	CustomerName        string              `json:"customerName,omitempty"`
	Premix              bool                `json:"premix"`
	DmPercTot           float64             `json:"dmPercTot,omitempty"`
	RecipeIngredient    []*recipeIngredient `json:"recipeIngredient,omitempty"`
}

type recipeIngredient struct {
	IngredientId   int     `json:"ingredientId,omitempty"`   // 成分ID
	IngredientName string  `json:"ingredientName,omitempty"` // 成分名称
	WeightCow      float64 `json:"weightCow,omitempty"`      // 重量
	DmPerc         float64 `json:"dmPerc,omitempty"`         // 干物质
	Position       int     `json:"position,omitempty"`       // 成分顺序
	IngredientCost float64 `json:"ingredientCost,omitempty"` // 成分成本
}

type DryMatterResponse struct {
	OdataContext string             `json:"@odata.context"`
	OdataCount   int                `json:"@odata.count"`
	Value        []*DryMatterValues `json:"value,omitempty"`
}

type DryMatterValues struct {
	DmId       int     `json:"dmId,omitempty"`
	Name       string  `json:"name,omitempty"`
	Weight     float64 `json:"weight,omitempty"`
	Enabled    bool    `json:"enabled,omitempty"`
	LastModify string  `json:"lastModify,omitempty"`
	RowVersion string  `json:"rowVersion,omitempty"`
	Factory    bool    `json:"factory,omitempty"`
	CustomerId int     `json:"customerId,omitempty"`
}

type BatchResponse struct {
	OdataContext string         `json:"@odata.context"`
	OdataCount   int            `json:"@odata.count"`
	Value        []*BatchValues `json:"value"`
}

type BatchValues struct {
	BatchId        int               `json:"batchId,omitempty"`
	Name           string            `json:"name,omitempty"`
	StartTime      string            `json:"startTime,omitempty"`
	Mon            bool              `json:"mon,omitempty"`
	Tue            bool              `json:"tue,omitempty"`
	Wed            bool              `json:"wed,omitempty"`
	Thu            bool              `json:"thu,omitempty"`
	Fri            bool              `json:"fri,omitempty"`
	Sat            bool              `json:"sat,omitempty"`
	Sun            bool              `json:"sun,omitempty"`
	AllWeek        bool              `json:"allWeek,omitempty"`
	MixTime        int               `json:"mixTime,omitempty"`
	Note           string            `json:"note,omitempty"`
	Enabled        bool              `json:"enabled,omitempty"`
	RecipeId       int               `json:"recipeId,omitempty"`
	RecipeName     string            `json:"recipeName,omitempty"`
	LastModify     string            `json:"lastModify,omitempty"`
	AdjPerc        float64           `json:"adjPerc,omitempty"`
	RowVersion     string            `json:"rowVersion,omitempty"`
	Machines       []int             `json:"machines,omitempty"`
	TotalWeight    float64           `json:"totalWeight,omitempty"`
	Premix         bool              `json:"premix,omitempty"`
	BatchPenRation []*BatchPenRation `json:"batchPenRation,omitempty"`
}

type BatchPenRation struct {
	RationNumber     int     `json:"rationNumber,omitempty"`
	PenId            int     `json:"penId,omitempty"`
	PenName          string  `json:"penName,omitempty"`
	NCows            int     `json:"ncows,omitempty"`
	RationPerc       float64 `json:"rationPerc,omitempty"`
	RationPercAdj    float64 `json:"rationPercAdj,omitempty"`
	RecipeId         int     `json:"recipeId,omitempty"`
	RecipeName       string  `json:"recipeName,omitempty"`
	NewWeightCow     float64 `json:"newWeightCow,omitempty"`
	NewTotalWeight   float64 `json:"newTotalWeight,omitempty"`
	NewDmWeightCow   float64 `json:"newDmWeightCow,omitempty"`
	NewDmTotalWeight float64 `json:"newDmTotalWeight,omitempty"`
	Position         int     `json:"position,omitempty"`
	AutomaticSkip    bool    `json:"automaticSkip,omitempty"`
}

type BatchHistDetailResponse struct {
	OdataContext string                  `json:"@odata.context"`
	OdataCount   int                     `json:"@odata.count"`
	Value        []*BatchHistDetailValue `json:"value,omitempty"`
}

type BatchHistDetailValue struct {
	ElabLoadId        int           `json:"elabLoadId"`
	ElabUnloadId      int           `json:"elabUnloadId"`
	BatchId           int           `json:"batchId"`
	BatchName         string        `json:"batchName"`
	Premix            bool          `json:"premix"`
	LoadDate          string        `json:"loadDate"`
	LoadStartTime     string        `json:"loadStartTime"`
	LoadEndTime       string        `json:"loadEndTime"`
	UnloadDate        string        `json:"unloadDate"`
	UnloadStartTime   string        `json:"unloadStartTime"`
	UnloadEndTime     string        `json:"unloadEndTime"`
	RecipeId          int           `json:"recipeId"`
	RecipeName        string        `json:"recipeName"`
	RecipeTotalWeight float64       `json:"recipeTotalWeight"`
	Ingredients       []*Ingredient `json:"ingredients,omitempty"`
	Pens              []*Pen        `json:"pens,omitempty"`
}

type Ingredient struct {
	IngredientId        int     `json:"ingredientId"`
	IngredientName      string  `json:"ingredientName"`
	TargetWeight        float64 `json:"targetWeight"`
	TargetWeightOnScale float64 `json:"targetWeightOnScale"`
	DmTotalWeight       float64 `json:"dmTotalWeight"`
	Loaded              float64 `json:"loaded"`
	ErrPerc             float64 `json:"errPerc"`
	ProgrammedCost      float64 `json:"programmedCost"`
	LoadedCost          float64 `json:"loadedCost"`
	OverfeedCost        float64 `json:"overfeedCost"`
	StartTime           string  `json:"startTime"`
	EndTime             string  `json:"endTime"`
	FeederQtyErrWeight  float64 `json:"feederQtyErrWeight"`
	Premix              bool    `json:"premix"`
	LoadPercAbs         float64 `json:"loadPercAbs"`
}

type Pen struct {
	penId                       int     `json:"penId"`
	penName                     string  `json:"penName"`
	targetWeight                float64 `json:"targetWeight"`
	loadedTargetWeightOnScale   float64 `json:"loadedTargetWeightOnScale"`
	loaded                      float64 `json:"loaded"`
	loadedErrPerc               float64 `json:"loadedErrPerc"`
	unloadedTargetWeightOnScale float64 `json:"unloadedTargetWeightOnScale"`
	unloaded                    float64 `json:"unloaded"`
	unloadedErrPerc             float64 `json:"unloadedErrPerc"`
	ncowsTheo                   int     `json:"ncowsTheo"`
	ncows                       int     `json:"ncows"`
	startTime                   string  `json:"startTime"`
	endTime                     string  `json:"endTime"`
}
